<?php

use console\db\Migration;

/**
 * 创建圈子聚合信息表
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m190102_180239_t_group_assemble extends Migration {

    /**
     * {@inheritdoc}
     */
    public function up() {

        /**
         * 圈子聚合信息表
         * @table `sns_group_assemble`
         */
        $this->tableBuilder([
            'name' => 'sns_group_assemble',
            'comment' => '圈子聚合信息表',
            'columns' => [
                'id' => $this->primaryKey(),
                'group_id' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('圈子ID'),
                'name' => $this->char(20)->notNull()->comment('聚合标识'),
                'label' => $this->string(50)->notNull()->comment('聚合名称'),
                'icon' => $this->char(255)->defaultValue('')->comment('默认图标'),
                'temp_icon' => $this->char(255)->defaultValue('')->comment('缓存图标'),
                'nums' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('动态数量'),
                'listorder' => $this->integer(11)->unsigned()->notNull()->defaultValue(0)->comment('显示排序'),
                'status' => $this->tinyint(1)->notNull()->defaultValue(10)->comment('状态'),
                'created_at' => $this->unixTimestamp()->comment('创建时间'),
                'updated_at' => $this->unixTimestamp()->comment('更新时间'),
            ],
            'index' => [
                [
                    'columns' => ['group_id', 'name'],
                    'unique' => true
                ],
            ]
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function down() {
        $this->dropTable('{{%sns_group_assemble}}');
    }

}
